from django.db import models


from authApp.models import UserInfo


# Create your models here.

class InformationCategory(models.Model):
    name = models.CharField("类别", max_length=200)

class Information(models.Model):
    title = models.CharField("标题",max_length=200)
    author = models.ForeignKey(UserInfo, on_delete=models.CASCADE)
    author_name = models.CharField("作者", max_length=200,null=True)
    content = models.TextField("内容")
    pub_time = models.DateTimeField("发布时间",auto_now_add=True)
    category = models.ForeignKey(InformationCategory, on_delete=models.CASCADE)
    data_source = models.TextField("数据源")


class InformationComment(models.Model):
    content = models.TextField("内容")
    author = models.ForeignKey(UserInfo, on_delete=models.CASCADE,verbose_name="评论人")
    information = models.ForeignKey(Information, related_name='comments',on_delete=models.CASCADE,verbose_name="所属资料")
    pub_time = models.DateTimeField("评论时间", auto_now_add=True)